# Active scene - is a special global variable which contains all system reserved routines
ActiveScene.systemInitialize = function ()
	ActiveScene.handlers = {
		emptyFunc = function ()
			-- does nothing...
		end;
		
		guiGameRestart = function ()
			Player.New();
			World.LoadLocation();
		end;
		
		guiGameEnd = function ()
			Game.SetScene('main_menu');
		end;

	};

	guiGameRestart = ActiveScene.handlers.guiGameRestart;
	guiGameEnd = ActiveScene.handlers.guiGameEnd;

	-- That might be redefined
	onLoad = ActiveScene.handlers.emptyFunc;
	onTime = ActiveScene.handlers.emptyFunc;
	onUnload = ActiveScene.handlers.emptyFunc;

	-- The world location must be set before we reach that line of code
	-- Called with no arguments, it loads the preset location of given world
	World.LoadLocation();

end

ActiveScene.systemOnLoad = function ()
	-- Occures ones the world location is loaded
	onLoad();
	Game.Log('load called');
end

ActiveScene.systemOnTime = function (Year, Month, Day, Time)
	-- Periodic event
	onTime(Year, Month, Day, Time);

end

ActiveScene.systemOnUnload = function ()
	Game.Log('unload called');
	-- Occures before the world location is unloaded
	onUnload();

	onLoad = ActiveScene.handlers.emptyFunc;
	onTime = ActiveScene.handlers.emptyFunc;
	onUnload = ActiveScene.handlers.emptyFunc;
end

ActiveScene.systemFinalize = function ()
	-- If not any location is active, that will be just skipped
	World.UnloadLocation();
	-- Does not actually unload resources but wipe it off
	Player.Clear();

	-- Clear container
	ActiveScene.handlers = nil;
		-- Scene unique handlers
		ActiveScene.systemOnLoad = nil;
		ActiveScene.systemOnTime = nil;
		ActiveScene.systemOnUnload = nil;

	-- Clear global shortcuts
	guiGameRestart = nil;
	guiGameEnd = nil;
	onLoad = nil;
	onTime = nil;
	onUnload = nil;

end

--[[
	Thus, these handlers can be re-defined by individual level scripting files:
		onLoad () -- oneshot event, occures on world location ready event
		onTime (Year, Month, Day, Time) -- periodic event, occures each time TICK
		onUnload () -- oneshot event, occures on world location before finalize event
]]--